package com.woniuxy.commons.rabbbitMQ.configuration;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfiguration {
    @Bean
    public DirectExchange mainExchange() {
        return new DirectExchange("main_exchange");
    }
    @Bean
    public Queue logQueue() {
        return new Queue("log");
    }
    // 绑定消息队列和交换机：需要指定路由
    @Bean
    public Binding bindingLogQueueToMainExchange(Queue logQueue, DirectExchange mainExchange){
        return BindingBuilder.bind(logQueue).to(mainExchange).with("log");
    }

}